<template>
	<div>
		<el-table :data="showData" style="width: 100%">
			<el-table-column prop="id" label="id" width="180">
			</el-table-column>
			<el-table-column prop="users.user_name" label="用户" width="300">
			</el-table-column>
			<el-table-column prop="payAmount" align="center" label="支付金额">
			</el-table-column>
			<el-table-column prop="totalAmount" align="center" label="下单金额">
			</el-table-column>
			<el-table-column prop="commission" align="center" label="返佣金额">
			</el-table-column>
			<el-table-column prop="type" label="支付类型">
				<template slot-scope="scope">
					<span v-if="scope.row.type === 1">线上支付</span>
					<span v-else-if="scope.row.type === 2">聚合支付</span>
					<span v-else>无</span>
				</template>
			</el-table-column>
			<el-table-column prop="create_time" label="时间">
			</el-table-column>
		</el-table>
		<div class="whole-pagination">
			<el-pagination background layout="prev, pager, next" :total="count"  @current-change = "changePage">
			</el-pagination>
		</div>
	</div>
</template>

<script>
	export default {
		data() {
			return {
				agentID: this.$store.state.userId ? this.$store.state.userId : JSON.parse(window.localStorage.userInfo).userId,
				type: 1,
				limit: 10,
				count: 0,
				showData: []
			}
		},
		created() {
			this.getData(1, this.type);
		},
		methods: {
			getData(page, type) {
				let that = this;
				that.$axios({
					url: '/admin/agent/getIncome',
					method: 'POST',
					data: {
						agentID: that.agentID,
						type: type,
						offset: page,
						limit: that.limit,
					},
					success(res) {
						if (res.data.code == 200) {
							that.showData = res.data.content.data;
						  that.count = res.data.content.count;
						} else {
							that.$message(res.data.msg);
						}
					}
				});
			},
			changePage(page){
				this.getData(page,this.type);
			}
		}

	}
</script>
